<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

<script type="text/javascript" src="<c:url value="/layout/javascript/largePaginator.js"/>">/**/</script>
<script type="text/javascript" src="<c:url value="/layout/javascript/jquery.form.js"/>">/**/</script> 
<script type="text/javascript" src="<c:url value="/layout/javascript/form.js"/>">/**/</script>
<script type="text/javascript" src="<c:url value="/layout/javascript/form.admin.js"/>">/**/</script>

<script type="text/javascript">
var floorErrOpts = {
    msg : "<bean:message key="floor.load.msg" bundle="errors"/>",
    boxTitle : "<bean:message key="floor.load.boxTitle" bundle="errors"/>",
    msgStatus: "<bean:message key="floor.load.msgStatus" bundle="errors"/>"
};

var confirmDeleteOfficeOpts = {
    msg : "<bean:message key="office.delconfirm.msg" bundle="errors"/>",
    boxTitle : "<bean:message key="office.delconfirm.boxTitle" bundle="errors"/>",
    msgStatus: "<bean:message key="office.delconfirm.msgStatus" bundle="errors"/>" 
};

$(document).ready(function() {
	var options = { 
        //target:        '#hiddenresult', 
        beforeSubmit:  function () {
                           $('#Searchresult').empty();
                           $('#Searchresult').html('<img alt="<bean:message key="wait.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="wait.message"/>');
                       }, 
        success:       function (data) {
				            var identity = data.slice(0,68);
				            // Riceve come risposta il box di errore di validazione
				            if (identity.search('#boxvalidation') != -1) {
				                $('#validationbox').html(data);
				                $('#Searchresult').empty();
				            } else { // Riceve la lista di uffici
				               $('#hiddenresult').html(data);
				               initPagination(null);
				            }
				       },       
        error:         function () {
                           showErrorDialog('#dialog', 
                                   { msg: "<bean:message key="office.history.form.msg" bundle="errors"/>",
                                     boxTitle: "<bean:message key="office.history.form.boxTitle" bundle="errors"/>",
                                     msgStatus: "<bean:message key="office.history.form.msgStatus" bundle="errors"/>" });
                       }  
     };

     $('#form_OH').ajaxForm(options);
	    
     $('#form_OH').submit();
	
    
	 $("#building").change(function() {
		 selectFloor($(this), '${pageContext.request.contextPath}/admin/loadbuildingfloor.do', null);
	 });

	 selectFloor($('#floor'), '${pageContext.request.contextPath}/admin/loadbuildingfloor.do', function() {
		 $('#form_OH').submit(); 
	 });
});
</script>

<div id="content">
		<fieldset id="fieldset">
			<legend class="fieldsetLabel"><bean:message key="office.history" bundle="office"/></legend>
			<div id="form_containerOH">
				<html:form styleId="form_OH" styleClass="appnitro" action="/admin/officelist.do">
				<div id="divOH">	
					<ul id="ulOH">
					<li id="li_1OH" >
						<label class="description" for="building"><bean:message key="office.building" bundle="office"/></label>
						<div>
						    <html:select property="building" styleClass="element select large" styleId="building">
                                <option  selected="selected" value=""><bean:message key="select.option.all"/></option>
                                <html:options name="buildings"/>
                            </html:select>  
						</div> 
					</li>
					<li id="li_2OH" >
						<label class="description" for="floor"><bean:message key="office.floor" bundle="office"/></label>
						<div>
							<select name="floor" class="element select large" id="floor">
							</select>
						</div> 
					</li>				
					<li id="buttonsOH">
						<html:submit styleId="searchButton" styleClass="button_text">
                          <bean:message key="button.search"/>
                        </html:submit>
					</li>
					</ul>
				</div>	
				</html:form>	
				
				<div id="ListOfficeHistory">
					<div id="Pagination" class="pagination"> </div>
					<br style="clear:both;" />
					<ul id="label">
                        <li class="LORNumber"><bean:message key="office.roomnumber" bundle="office"/></li>
                        <li class="LOBuilding"><bean:message key="office.building" bundle="office"/></li>
                        <li class="LOFloor"><bean:message key="office.floor" bundle="office"/></li>
                        <li class="LOName"><bean:message key="office.name" bundle="office"/></li>
                        <li class="LOPhone"><bean:message key="office.phone" bundle="office"/></li>
                    </ul>
					<div id="Searchresult">
						<img alt="<bean:message key="wait.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="wait.message"/>
					</div>
			        
			        <!-- Container element for all the Elements that are to be paginated -->
			        <div id="hiddenresult" style="display:none;">
			        </div>
				</div>
			</div>				
		</fieldset>	
</div>